package com.zhubayi.service.impl;

import com.zhubayi.entity.Admin;
import com.zhubayi.mapper.AdminMapper;
import com.zhubayi.service.AdminService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 祝八一
 */
@Service
public class AdminServiceImpl implements AdminService {
    @Autowired
    AdminMapper adminMapper;
    /**
     * 登录
     *
     * @param admin
     * @return
     */
    @Override
    public boolean login(Admin admin) {
        Admin admin1 = adminMapper.queryByName(admin);
       if (admin1==null){
           return false;
       }
        return true;
    }

    /**
     * 查询所有
     *
     * @return
     */
    @Override
    public List<Admin> queryAll() {
        return null;
    }

    /**
     * 检查密码是否对
     *
     * @param id
     * @param oldPwd
     * @return
     */
    @Override
    public boolean CheckOldPwd(Integer id, String oldPwd) {
        Admin admin = adminMapper.CheckOldPwd(id, oldPwd);
        if (admin==null){
            return false;
        }
        return true;
    }

    /**
     * 修改密码
     *
     * @param id
     * @param newPwd
     */
    @Override
    public void updatePassword(Integer id, String newPwd) {
        adminMapper.updatePassword(id, newPwd);

    }
}
